﻿#region Copyright
//       Copyright (c) 2009 - Antoine Jaussoin - http://www.jaussoin.com/blog/
// 
//        This program is free software: you can redistribute it and/or modify
//        it under the terms of the GNU General Public License as published by
//        the Free Software Foundation, either version 3 of the License, or
//        (at your option) any later version.
// 
//        This program is distributed in the hope that it will be useful,
//        but WITHOUT ANY WARRANTY; without even the implied warranty of
//        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//        GNU General Public License for more details.
// 
//        You should have received a copy of the GNU General Public License
//        along with this program.  If not, see <http://www.gnu.org/licenses/>.
#endregion
using System;
using FT.Architecture.UnitOfWork;

namespace FT.Architecture.Exceptions
{
    /// <summary>
    /// Exception occurring in a Unit Of Work context
    /// </summary>
    public class UnitOfWorkException : Exception
    {
        private readonly IUnitOfWork unitOfWork;

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="unitOfWork"></param>
        public UnitOfWorkException(IUnitOfWork unitOfWork)
        {
            this.unitOfWork = unitOfWork;
        }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="message"></param>
        /// <param name="unitOfWork"></param>
        public UnitOfWorkException(string message, IUnitOfWork unitOfWork)
            : base(message)
        {
            this.unitOfWork = unitOfWork;
        }

        /// <summary>
        /// Constructor
        /// </summary>
        public UnitOfWorkException()
        {
        }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="message"></param>
        public UnitOfWorkException(string message)
            : base(message)
        {
        }

        /// <summary>
        /// Faulty unit of work
        /// </summary>
        public IUnitOfWork UnitOfWork
        {
            get { return unitOfWork; }
        }
    }
}
